package com.taotao.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.taotao.mapper.TbItemMapper;
import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemExample;
import com.taotao.pojo.TbItemExample.Criteria;
import com.taotao.service.ItemService;

/**
 * 商品管理service
 * <p>Title: ItemServiceImpl</p>
 * <p>Description: </p>
 * <p>Company: www.taotao.com</p> 
 * @author	lxt
 * @date	2017年3月5日下午3:40:09
 * @version 1.0
 */
@Service
public class ItemServiceImpl implements ItemService {

	@Autowired
	private TbItemMapper itemMapper;
	
	@Override
	public TbItem getItemById(long itemId) {
		
//		TbItem item = itemMapper.selectByPrimaryKey(itemId);
		
		//添加查询条件
		TbItemExample example = new TbItemExample();
		Criteria criteria = example.createCriteria();
		criteria.andIdEqualTo(itemId);
		System.out.println("before");
		List<TbItem> itemList = itemMapper.selectByExample(example);
		System.out.println("after");
		if(itemList !=null &&itemList.size() > 0){
			TbItem item = itemList.get(0);
			return item;
		}
		
		return null;
	}

}
